<?php $this->headScript()->appendFile($this->baseUrl() . "/plugins/datatables/jquery.dataTables.min.js","text/javascript"); ?>
<?php $this->headScript()->appendFile($this->baseUrl() . "/plugins/validate/jquery.validate.js","text/javascript"); ?>
<?php $this->headScript()->appendFile($this->baseUrl() . "/js/modules/safety/Privilege.js","text/javascript"); ?>
<?php $this->headScript()->appendFile($this->baseUrl() . "/js/demo/demo.tables.js","text/javascript"); ?>

<?php $this->headScript()->captureStart(); ?>
	$(document).ready(function() {	
		var privileges = new com.em.Privilege();
		privileges.setUrl({
			toTable : '<?php echo $this->url(array('action'=>'read-items')); ?>',
		});
		privileges.setValidatorForm('#form-privilege');
		privileges.configureTable('#tblprivileges');
		privileges.configureDropDown('#roleFilter', '#moduleFilter', '#controllerFilter', '#actionFilter');
		privileges.clickToAdd('#addPrivilege');
		privileges.clickToDelete('#removePrivilege');
	});
<?php $this->headScript()->captureEnd(); ?>
								
						<div class="grid_4">
                        	<div class="da-panel collapsible">
                            	<div class="da-panel-header">
                                	<span class="da-panel-title">
                                        <img src="/images/icons/black/16/list.png" alt="" />
                                        <?php echo $this->translate('List Privileges'); ?>
                                    </span>
                                </div>
                                <div class="da-panel-content">
                                    <div class="da-panel-content">
	                                	<form id="form-privilege" class="da-form">
	                                		<div class="da-form-row">
	                                        	<div class="da-form-col-2-8">
												    <label>Roles</label>
													<select id="roleFilter" name="roleFilter">
	                                                	<option></option>
	                                                	<?php foreach ($this->roles as $role) : ?>
		                                                	<option value="<?php echo $role->getId(); ?>"><?php echo $role->getName(); ?></option>
														<?php endforeach; ?>
													</select>
											    </div>
											</div>
	                                        <div class="da-form-row">
	                                        	<div class="da-form-col-2-8">
												    <label>Modules</label>
													<select id="moduleFilter" name="moduleFilter" src="<?php echo $this->url(array('controller'=>'reflection', 'action'=>'read-controllers', 'format'=>'html')); ?>" srcmodules="<?php echo $this->url(array('controller'=>'reflection', 'action'=>'read-modules', 'format'=>'html')); ?>">
	                                                	<option value="%">%</option>
													</select>
											    </div>
											    <div class="da-form-col-2-8">
											        <label>Controllers</label>
	                                                <select id="controllerFilter" name="controllerFilter" src="<?php echo $this->url(array('controller'=>'reflection', 'action'=>'read-actions', 'format'=>'html')); ?>">
	                                                	<option value="%">%</option>
													</select>
											    </div>
											    <div class="da-form-col-2-8">
											        <label>Actions</label>
	                                                <select id="actionFilter" name="actionFilter">
	                                                	<option value="%">%</option>
													</select>
											    </div>
											    <div class="da-form-col-2-8">
											        <label>Click to Add</label>
	                                                <input type="submit" href="<?php echo $this->url(array('controller'=>'privilege', 'action'=>'create-save')); ?>" class="da-button red large" id="addPrivilege" value="Add">
											    </div>
											</div>
	                            		</form>
										<table class="da-table" id="tblprivileges">
	                                        <thead>
	                                            <tr>
	                                            	<th><input type="checkbox" value="0"></th>
													<th><?php echo $this->translate('Module'); ?></th>
													<th><?php echo $this->translate('Controller'); ?></th>
													<th><?php echo $this->translate('Action'); ?></th>
	                                            </tr>
	                                        </thead>
	                                        <tbody>
	                                            
	                                        </tbody>
	                                    </table>
									</div>
                                </div>
                            </div>
                        </div>
                       
                        <div id="dialog-form">
							<!--	load ajax dialog form	-->
						</div>
						